﻿Public Class CreateForm
    Implements IForm

    Private _前缀 As String = ""

    Public Sub LoadMenu(ByVal ms As System.Windows.Forms.MenuStrip, ByVal 前缀 As String) Implements IListenDb.IForm.LoadMenu

    End Sub

    Private Sub RefreshStatus(ByVal tsb暂停监听 As System.Windows.Forms.ToolStripButton, ByVal 前缀 As String)

        Try

            Dim dt As DataTable = IListenDb.CommonConUtil.GetTable("Select * from " & 前缀 + "_Control")
            If dt.Rows.Count > 0 Then
                If CInt(dt.Rows(0)("X002Status")) = 1 Then
                    tsb暂停监听.Text = "自动快照(XSC)-停止"
                    tsb暂停监听.ForeColor = System.Drawing.SystemColors.ControlText
                Else
                    tsb暂停监听.Text = "自动快照(XSC)"
                    tsb暂停监听.ForeColor = System.Drawing.Color.Red
                End If
            End If

        Catch ex As Exception

        End Try

    End Sub

    Public Sub LoadToolBar(ByVal ts As System.Windows.Forms.ToolStrip, ByVal 前缀 As String) Implements IListenDb.IForm.LoadToolBar

        Dim tsb暂停监听 As System.Windows.Forms.ToolStripButton
        Dim ToolStripSeparator5 As System.Windows.Forms.ToolStripSeparator

        ToolStripSeparator5 = New System.Windows.Forms.ToolStripSeparator
        _前缀 = 前缀
        ToolStripSeparator5.Name = "ToolStripSeparator5"
        ToolStripSeparator5.Size = New System.Drawing.Size(6, 25)
        ts.Items.Add(ToolStripSeparator5)

        'tsb暂停监听
        '
        tsb暂停监听 = New System.Windows.Forms.ToolStripButton
        tsb暂停监听.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text
        tsb暂停监听.ImageTransparentColor = System.Drawing.Color.Magenta
        tsb暂停监听.Name = "tsb自动快照"
        tsb暂停监听.Size = New System.Drawing.Size(57, 22)
        tsb暂停监听.Text = "自动快照(XSC)-停止"
        AddHandler tsb暂停监听.Click, AddressOf tsb暂停监听_Click
        ts.Items.Add(tsb暂停监听)

        RefreshStatus(tsb暂停监听, _前缀)
    End Sub

    Private Sub tsb暂停监听_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        Dim tsb暂停监听 As System.Windows.Forms.ToolStripButton = CType(sender, System.Windows.Forms.ToolStripButton)

        If tsb暂停监听 Is Nothing Then
            Exit Sub
        End If

        Dim strsql As String = "Update " & _前缀 + "_Control Set X002Status=0 where Kubun='001'"
        If tsb暂停监听.Text = "自动快照(XSC)" Then
            strsql = "Update " & _前缀 + "_Control Set [X002Status]= 1 where Kubun='001'"
            tsb暂停监听.Text = "自动快照(XSC)-停止"
        Else
            strsql = "Update " & _前缀 + "_Control Set [X002Status]= 0 where Kubun='001'"
            tsb暂停监听.Text = "自动快照(XSC)"
        End If

        IListenDb.CommonConUtil.ExecuteSql(strsql)
        RefreshStatus(tsb暂停监听, _前缀)

        IListenDb.CommonConUtil.CloseCon()

    End Sub

    Public Sub InitForm(ByVal ms As System.Windows.Forms.MenuStrip, ByVal ts As System.Windows.Forms.ToolStrip, ByVal 前缀 As String) Implements IListenDb.IForm.InitForm
        Try

            Dim tsb暂停监听 As System.Windows.Forms.ToolStripButton = CType(ts.Items("tsb自动快照"), System.Windows.Forms.ToolStripButton)

            RefreshStatus(tsb暂停监听, _前缀)

        Catch ex As Exception

        End Try
    End Sub

End Class

